<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> 
  <head>
    <base href="<%=basePath%>" />
    <title>Menu List</title>
    <script type="text/javascript">
		var path = "<%=basePath%>";
	</script>
	<meta http-equiv="pragma" content="no-cache" />
	<meta http-equiv="cache-control" content="no-cache" />
	<meta http-equiv="expires" content="0" />    
	<link rel="stylesheet" type="text/css" href="<%=basePath%>basic/css/content.css" />
	<!-- 页面特效 -->
	<jsp:include page="/basic/res-refer/page-effect-reference.jsp" />
	<!-- 系统通用资源 -->
	<jsp:include page="/resources/resource-refer/common-resource-reference.jsp" />
	<!-- 用户访问菜单路径 -->
	<jsp:include page="/resources/usertrace/common-uservisit-reference.jsp" />
  </head>
  <script type="text/javascript">
  	function addNewMenu() {
  		var parentMenuID = "<s:property value='parentMenuID' />";
  		loadNewModal(path+"basic/menuAction!queryMenuForManage.do?parentMenuID="+parentMenuID+"&date="+new Date(),"Add menu","410px","500px");
  	}
  	
  	function updateMenu(menuID) {
  		var parentMenuID = "<s:property value='parentMenuID' />";
  		loadNewModal(path+"basic/menuAction!queryMenuForManage.do?menuID="+menuID+"&parentMenuID="+parentMenuID+"&date="+new Date(),"Modify the menu","410px","500px");
  	}
  	
  	function deleteMenu(menuID) {
  		var parentMenuID = "<s:property value='parentMenuID' />";
  		Dialog.confirm("Are you sure to delete this menu?", function(){
  			$.getJSON(path+"basic/menuActionJson!deleteMenuByID.do?date="+new Date(), {
  	  			menuID: menuID
  	  		}, function(data) {
  	  			if(data.success) {
  	  				Dialog.alert("Successful Operation！", function() {
	  	  				window.location = path + "basic/menuAction!queryByParentMenuID.do?parentMenuID="+parentMenuID;
	  	  				parent.window.frames["menuMgr"].location = path + "basic/jsp/menuMgrTree.jsp?date="+new Date();
  	  				});
  	  			} else {
  	  				Dialog.alert(data.msg);
  	  			}
  	  		});
  		});
  	}
  	
  	$(function(){
  		$("input[name='query']").click(function(){
  			var menuName = $("input[name='menuName']").val();
  			window.location = path + "basic/menuAction!queryByMenuName.do?menuName="+encodeURIComponent(menuName)+"&date="+new Date();
  		});
  		$("input[name='add']").click(function(){
  			addNewMenu();
  		});
  	});
  </script>
  <body>
  	<div class="content_all">
	  	<!--查询条件-->
	  	<div class="search">
	    	<table cellpadding="0" cellspacing="0">
	      		<tr>
	        		<th>Menu Name：</th>
			        <td><input name="menuName" value="<s:property value='menuName' />" type="text" class="s_input" /></td>
			        <td><input name="query" type="button" value="Query" class="s_btn" />
	        			<input name="add" type="button" value="Add" class="s_btn" /></td>
	      		</tr>
	    	</table>
	  	</div>
	  	<!--查询列表-->
	  	<div class="search_table_all">
	    	<table class="search_table" cellspacing="0" cellpadding="0">
	      		<thead>
	        		<tr>
		          		<th style="width:50px;">Serial No.</th>
			          	<th>Menu Name</th>
			          	<th>Function Link</th>
			          	<th>Icon Link</th>
			          	<th>Display Sequence</th>
			          	<th>Operation</th>
	        		</tr>
	      		</thead>
	      		<tbody>
	      			<s:iterator value="menuList" var="menu" status="status">
	      				<tr>
		          			<td><s:property value="#status.index+1" /></td>
		          			<td><s:property value="#menu.menuName" /></td>
		          			<td><s:property value="#menu.menuAction" /></td>
		          			<td>
		          				<s:if test="#menu.menuIcon!=null && #menu.menuIcon!=''">
		          					<img src="<%=basePath%><s:property value='#menu.menuIcon' />" />
		          				</s:if>
		          			</td>
		          			<td><s:property value="#menu.orderID" /></td>
		          			<td><a href="javascript:updateMenu('<s:property value='#menu.id' />')">[Modify]</a>&nbsp;&nbsp;
		          				<a href="javascript:deleteMenu('<s:property value='#menu.id' />')">[Delete]</a></td>
		        		</tr>
	      			</s:iterator>
	      		</tbody>
	    	</table>
	  	</div>
	</div>
  </body>
</html>
